package zx.x.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.sys.entity.WarehousingEntity;
import zx.x.modules.sys.service.WarehousingService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;



/**
 * 
 *
 * @author x
 * @email x
 * @date 2022-03-22 09:23:45
 */
@RestController
@RequestMapping("/sys/warehousing")
public class WarehousingController {
    @Autowired
    private WarehousingService warehousingService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("sys:warehousing:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = warehousingService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    // @RequiresPermissions("sys:warehousing:info")
    public R info(@PathVariable("id") Integer id){
		WarehousingEntity warehousing = warehousingService.getById(id);

        return R.ok().put("warehousing", warehousing);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //  @RequiresPermissions("sys:warehousing:save")
    public R save(@RequestBody List<WarehousingEntity> warehousingList){
        for (WarehousingEntity o : warehousingList){
            warehousingService.save(o);
        }
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //  @RequiresPermissions("sys:warehousing:update")
    public R update(@RequestBody WarehousingEntity warehousing){
		warehousingService.updateById(warehousing);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //  @RequiresPermissions("sys:warehousing:delete")
    public R delete(@RequestBody Integer[] ids){
		warehousingService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @RequestMapping("/queryList")
    public R queryList(int pageNum,int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        return R.ok().put("data", warehousingService.queryList());
    }
}
